import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { PetTitleInfo } from "./info/PetTitleInfo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class PetTitleConfig
    
    export  class PetTitleConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._allArray = [];
            if (PetTitleConfig._instance != null) 
            {
                throw new Error("PetTitleConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_pet_title_config.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new PetTitleInfo();
                loc1.code = loc2.code;
                loc1.category = loc2.category;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.type = loc2.type;
                loc1.level = loc2.level;
                loc1.stacking = loc2.stacking;
                loc1.belong = loc2.belong;
                loc1.existTime = loc2.existTime;
                loc1.desc = loc2.desc;
                loc1.attribute = loc2.attribute;
                loc1.iconType = loc2.iconType;
                loc1.icon = loc2.icon;
                loc1.condition = loc2.condition;
                loc1.sexLimit = loc2.sexLimit;
                loc1.careerLimit = loc2.careerLimit;
                loc1.showType = loc2.showType;
                loc1.showArea = loc2.showArea;
                loc1.parse();
                this._map[loc1.code] = loc1;
                this._allArray.push(loc1);
            }
            return;
        }

        public getInfoByCode(arg1: int): PetTitleInfo
        {
            return this._map[arg1];
        }

        public getTitlesByShowType(arg1: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            while (loc3 < this._allArray.length) 
            {
                loc2 = this._allArray[loc3];
                if (loc2.showType == arg1) 
                {
                    loc1.push(loc2);
                }
                ++loc3;
            }
            return loc1;
        }

        public static get instance(): PetTitleConfig
        {
            if (PetTitleConfig._instance == null) 
            {
                PetTitleConfig._instance = new PetTitleConfig();
            }
            return PetTitleConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_allArray: Array<any>;

        /* internal */ static /* var */_instance: PetTitleConfig;
    }
